<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of GetState
 *
 * @author gaurav
 */


class RegistrationUtility {

   public function getStateDD() {

        $state = new StateDAO();
        $allState =  $state->getState();
   //     print_r($allState[0][0]);
        echo '<select name = "state" id = "state" onchange = "loadCity();">';
         echo '<option value = -1>-- Select --</option>';

       for($i = 0; $i < count($allState); $i++){
        echo '<option value ='.$allState[$i]->id.'>'.$allState[$i]->name.'</option>';

        
        }
        echo '</select>';
    } // getStateDD


    public function getCity($state){
        
        $city = new CityDAO();
        $allCity = $city->getCityByStateId($state);
        
          echo '<select name = "city" id = "city" >';
          echo '<option value = -1>-- Select --</option>';
         if(count($allCity) != 1){
       for($i = 0; $i < count($allCity); $i++){
       echo $allCity[$i]->id;
      echo '<option value ='.$allCity[$i]->id.'>'.$allCity[$i]->name.'</option>';


        }
         }
        echo '</select>';
    } //getCity ends here

    public function SaveRegistraion($fName, $lName, $password, $counrtyId, $stateId, $cityId, $email, $mobile){

         echo "savereg";
         $user = new UsersDAO();
         $existUser = $user->checkEmail($email);
         if($existUser == false){
        $result =  $user->setUser($fName, $lName, $password, $counrtyId, $stateId, $cityId, $email, $mobile);
         }else{
             echo 'user already exist';
         }
         echo $result;
    } // saveRegistraion function ends 
} // RegistrationUtility ends here


?>
